package com.lxmes.device.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.lxmes.device.domain.DeviceFailureCheck;
import com.lxmes.device.domain.DeviceFailureRepair;
import com.lxmes.device.domain.NcEmGzwx;
import com.lxmes.device.service.INcEmGzwxService;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.device.domain.NcEmGcyz;
import com.lxmes.device.service.INcEmGcyzService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 *  过程验证评价Controller
 * 
 * @author ruoyi
 * @date 2023-02-11
 */
@RestController
@RequestMapping("/device/gcyz")
public class NcEmGcyzController extends BaseController
{
    @Autowired
    private INcEmGcyzService ncEmGcyzService;

    /**
     * 查询 过程验证评价列表
     */
    @PreAuthorize("@ss.hasPermi('device:gcyz:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcEmGcyz ncEmGcyz)
    {
        startPage();
        List<NcEmGcyz> list = ncEmGcyzService.selectNcEmGcyzList(ncEmGcyz);
        return getDataTable(list);
    }
    /**
     * 通过报修单号获取设备故障维修验证详细信息
     */
    @GetMapping(value = "/getCheckInfo/{reportId}")
    public AjaxResult getCheckInfo(@PathVariable("reportId") String reportId)
    {
        return AjaxResult.success(ncEmGcyzService.selectDeviceFailureCheckByReportId(reportId));
    }
    /**
     * 导出 过程验证评价列表
     */
    @PreAuthorize("@ss.hasPermi('device:gcyz:export')")
    @Log(title = " 过程验证评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcEmGcyz ncEmGcyz)
    {
        List<NcEmGcyz> list = ncEmGcyzService.selectNcEmGcyzList(ncEmGcyz);
        ExcelUtil<NcEmGcyz> util = new ExcelUtil<NcEmGcyz>(NcEmGcyz.class);
        util.exportExcel(response, list, " 过程验证评价数据");
    }

    /**
     * 获取 过程验证评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('device:gcyz:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ncEmGcyzService.selectNcEmGcyzById(id));
    }

    /**
     * 新增 过程验证评价
     */
    @PreAuthorize("@ss.hasPermi('device:gcyz:add')")
    @Log(title = " 过程验证评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcEmGcyz ncEmGcyz)
    {
        return toAjax(ncEmGcyzService.insertNcEmGcyz(ncEmGcyz));
    }

    /**
     * 修改 过程验证评价
     */
    @PreAuthorize("@ss.hasPermi('device:gcyz:edit')")
    @Log(title = " 过程验证评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcEmGcyz ncEmGcyz)
    {
        return toAjax(ncEmGcyzService.updateNcEmGcyz(ncEmGcyz));
    }

    /**
     * 删除 过程验证评价
     */
    @PreAuthorize("@ss.hasPermi('device:gcyz:remove')")
    @Log(title = " 过程验证评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ncEmGcyzService.deleteNcEmGcyzByIds(ids));
    }

}
